﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IGGCore;

namespace IGGWindowApp.Panels
{
    public partial class PanelHeader : UserControl
    {
        public PanelHeader()
        {
            InitializeComponent();
            lblEdition.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
        }

        public void SetData(News news)
        {
            Size szee = TextRenderer.MeasureText(news.Title, new System.Drawing.Font("Segoe UI", 40F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))));
            lblNews1.Text = news.Title;
            if (szee.Width > 1400)
            {
                this.lblNews1.Font = new System.Drawing.Font("Segoe UI", 30F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            } 
            else if (szee.Width > 1300)
            {
                this.lblNews1.Font = new System.Drawing.Font("Segoe UI", 32F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            }
            else if (szee.Width > 1200)
            {
                this.lblNews1.Font = new System.Drawing.Font("Segoe UI", 36F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            }
            else if (szee.Width > 1100)
            {
                this.lblNews1.Font = new System.Drawing.Font("Segoe UI", 40F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            }
            else if (szee.Width > 1000)
            {
                this.lblNews1.Font = new System.Drawing.Font("Segoe UI", 42F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            }
            else
            {
                this.lblNews1.Font = new System.Drawing.Font("Segoe UI", 46F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            }
            //toolTip1.SetToolTip(lblNews1, news.Content);
            TimeSpan editionsSpan = DateTime.Now - new DateTime(2012, 02, 13);
            int days = ((int)Math.Floor(editionsSpan.TotalDays)) + 1;
            int volume = (((int)(days / 365)) + 1);
            int edition = days - ((volume-1) * 365);
            lblEdition.Text = "Volume " + volume + ", Edition #" + edition;
            lblEdition.Visible = true;
        }
    }
}
